/*
 * RF_Transmit.c
 *
 * Created: 4/11/2013 11:27:52 AM
 *  Author: Parag
 */ 

#ifndef	F_CPU
#define F_CPU 8000000
#endif


#include <avr/io.h>
#include <stdint.h>
#include <stdio.h>
#include <avr/sfr_defs.h>
#include <avr/delay.h>

extern FILE uart_stream;

int main(void)
{
	
    stderr = stdout = stdin = &uart_stream;	
	UARTInit();
	UBRRL = 207;				//baudrate 2400
	
	PORTB |= (1<<PB7);						// pullup resistor on down button set as input
	char low,high,data;
	
	low = 0XFF;
	high = 0X00;
	data = 'P';
	_delay_ms(1000);       // safe
	
    while(1)
    {
		if(bit_is_clear(PINB,PB7))
		{
			UARTPutch(high,stderr);
			UARTPutch(high,stderr);
			UARTPutch(low,stderr);
			UARTPutch('J',stderr);      // setup and calibrate recieving comparator
			
			UARTPutch('U',stderr);
			UARTPutch('U',stderr);
			UARTPutch(data,stderr);
			UARTPutch(~data,stderr);
			UARTPutch('Z',stderr);
			_delay_ms(500);
		}
		else
		{
			UARTPutch(low,stderr);
		}			 
					
			
    }
}